#include <iostream>
#include <vector>
#include <queue>
using namespace std;
const int N = 1e5 + 10;
vector<int> edges[N]; // 存储树
int n;
bool st[N]; // 记录是否遍历

void bfs()
{
    queue<int> q;
    q.push(1);

    while(q.size())
    {
        int u = q.front();q.pop();
        cout << u << " ";
        st[u] = true;
        for(auto v : edges[u])
        {
            if(!st[v])
            {
                q.push(v);
            }
        }
    }
}
int main()
{
    cin >> n;
    for(int i = 0;i < n - 1;i++)
    {
        int a, b;
        cin >> a >> b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    bfs();
    return 0;
}